// dllist-analysis.cc

#include "copyright.h"
#include "system.h"
#include "dllist-driver.h"
#include "dllist-analysis.h"

int S;
DLList* list_analysis;
//CaseOne's Remove fucntion.
//
void CaseOneRemove(int which){
	list_analysis->Remove();
}
//CaseOne reflects to docs's case 1.
//
void CaseOne(){
	printf("Dllist thread analysis case1.\n");
	printf("This case flects to case 1 in docs.\n");
	list_analysis = new DLList();
	char *str = "abcdefg";
	list_analysis->SortedInsert(str,3);
	list_analysis->SortedInsert(str+1,4);
	list_analysis->SortedInsert(str+2,5);
	char *str1="ABCDEFG";
	S=1;
	Thread *c1=new Thread("CaseOne's remove-thread");
	c1->Fork(CaseOneRemove,0);
	list_analysis->SortedInsert(str1,1);
	traversal(list_analysis);
	retraversal(list_analysis);
}
//CaseTwo's Insert fucntion.
//
void CaseTwoInsert(int which){
	char *str1="ABCDEFG";
	S=0;
	list_analysis->SortedInsert(str1,13);
	S=2;
}
//CaseTwo reflects to docs's case 2.
//
void CaseTwo(){
	printf("Dllist thread analysis case2.\n");
	printf("This case flects to case 2 in docs.\n");
	list_analysis=new DLList();
	char *str = "abcdefg";
	list_analysis->SortedInsert(str,10);
	list_analysis->SortedInsert(str+1,101);
	list_analysis->SortedInsert(str+2,202);
	
	S=2;
	Thread *c1=new Thread("CaseTwo's insert-thread");
	c1->Fork(CaseTwoInsert,0);
	list_analysis->SortedInsert(str+3,14);
	traversal(list_analysis);
	retraversal(list_analysis);
}
//CaseThree's Remove fucntion.
//
void CaseThreeRemove(int which){
	S=0;
	list_analysis->Remove();
	S=3;
}
//CaseThree reflects to docs's case 3.
//
void CaseThree(){
	printf("Dllist thread analysis case3.\n");
	printf("This case flects to case 3 in docs.\n");
	list_analysis=new DLList();
	char *str = "abcdefg";
	list_analysis->SortedInsert(str,10);
	list_analysis->SortedInsert(str+1,101);
	list_analysis->SortedInsert(str+2,202);
	
	S=3;
	Thread *c1=new Thread("CaseThree's Remove-thread");
	c1->Fork(CaseThreeRemove,0);
	list_analysis->Remove();
	traversal(list_analysis);
	retraversal(list_analysis);
}
//CaseFour's Remove fucntion.
//
void CaseFourRemove(int which){
	list_analysis->Remove();
}
//CaseFour reflects to docs's case 4.
//
void CaseFour(){
	printf("Dllist thread analysis case4.\n");
	printf("This case flects to case 4 in docs.\n");
	list_analysis=new DLList();
	char *str = "abcdefg";
	list_analysis->SortedInsert(str,10);
	list_analysis->SortedInsert(str+1,101);
	list_analysis->SortedInsert(str+2,202);
	
	S=4;
	Thread *c1=new Thread("CaseFour's Remove-thread");
	c1->Fork(CaseFourRemove,0);
	list_analysis->Remove();
	traversal(list_analysis);
	retraversal(list_analysis);
}